package com.bw.ppx.splash;

import com.bw.common.entity.LiveDataEntity;
import com.bw.common.livedatabus.LiveDataBus;
import com.bw.common.mvvm.viewmodel.BaseViewModel;
import com.bw.network_sdk.entity.BaseEntity;

import java.util.HashMap;
import java.util.Map;

public class SplashViewModel extends BaseViewModel<SplashModel> {

    @Override
    protected void initData() {
        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 3; i >=0; i--) {
                    LiveDataEntity liveDataEntity = new LiveDataEntity();
                    liveDataEntity.action = LiveDataEntity.LiveDataType.START_VIEW_MODEL;
                    Map<LiveDataEntity.LiveDataType,Object> map = new HashMap<>();
                    map.put(LiveDataEntity.LiveDataType.SPLASH_TIME,i);
                    liveDataEntity.data = map;
                    liveDataViewModel.post(liveDataEntity);
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }).start();
    }

    @Override
    protected void onRestle(BaseEntity entity) {

    }
}
